package com.nan.buy.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nan.buy.model.OrderDetails;
import com.nan.buy.model.Orders;
import com.nan.buy.service.OrdersService;

/**
 * 訂單信息管理
 * @author 孙楠楠
 *
 */
@Controller
@RequestMapping("order")
public class OrderController {

	@Resource
	private OrdersService ordersService;
	
	@RequestMapping("order")
	public String order(){
		return 	"admin/order";
	}
	@RequestMapping("orderRsetrieval")
	public String orderRsetrieval(){
		return 	"admin/orderRsetrieval";
	}
	/*
	 * 查詢所有點歌單信息
	 */
	@RequestMapping("search")
	@ResponseBody
	public List<Orders> selectOrders(){
		return ordersService.selectOrders();
	}
	
	/*
	 * 刪除訂單信息
	 */
	@RequestMapping("del")//先刪除子表
	@ResponseBody
	public Object delOrders(String oId){
		int msg=ordersService.delOrders(oId);
		return (msg != 0) ? true : false;
	}
	
	/*
	 * 查询某个订单信息
	 */
	@RequestMapping("selectByPrimaryKey")
	@ResponseBody
	public Orders selectByPrimaryKey(String orderId){
		return ordersService.selectByPrimaryKey(orderId);
	}
	
	/*
	 * 添加订单
	 */
	@RequestMapping("insert")
	@ResponseBody
	public Object insertOrders(List<OrderDetails> OrderDetailsList,Orders record){
		int msg=ordersService.insertOrders(OrderDetailsList,record);
		return (msg != 0) ? true : false;
	}
	
}
